package com.codeczx.breakpointresumedemo;

import java.util.concurrent.atomic.AtomicReference;

public class DownloadManager {

    private static final AtomicReference<DownloadManager> INSTANCE = new AtomicReference<>();

    private DownloadManager(){

    }

    public static DownloadManager getInstance(){
        for(;;){
            DownloadManager current = INSTANCE.get();
            if(current != null){
                return current;
            }
            current = new DownloadManager();
            if(INSTANCE.compareAndSet(null,current)){
                return current;
            }
        }
    }



}
